<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Date_converter {

   function converter_to_indonesian_date($input_format_yyymmdd,$mode_font=NULL,$sql_format='yes'){

      if($sql_format=='no')
      {
       $rule_month =array('1'=>'Januari',
                        '2'=>'Februari',
                        '3'=>'Maret',
                        '4'=>'April',
                        '5'=>'Mei',
                        '6'=>'Juni',
                        '7'=>'Juli',
                        '8'=>'Agustus',
                        '9'=>'September',
                        '10'=>'Oktober',
                        '11'=>'November',
                        '12'=>'Desember'
                        );

       $rule_day = array('1'=>'1',
                        '2'=>'2',
                        '3'=>'3',
                        '4'=>'4',
                        '5'=>'5',
                        '6'=>'6',
                        '7'=>'7',
                        '8'=>'8',
                        '9'=>'9',
                        );
      }
      else
      {
       $rule_month =array('01'=>'Januari',
                        '02'=>'Februari',
                        '03'=>'Maret',
                        '04'=>'April',
                        '05'=>'Mei',
                        '06'=>'Juni',
                        '07'=>'Juli',
                        '08'=>'Agustus',
                        '09'=>'September',
                        '10'=>'Oktober',
                        '11'=>'November',
                        '12'=>'Desember'
                        );

       $rule_day = array('01'=>'1',
                        '02'=>'2',
                        '03'=>'3',
                        '04'=>'4',
                        '05'=>'5',
                        '06'=>'6',
                        '07'=>'7',
                        '08'=>'8',
                        '09'=>'9',
                        );
      }

      if(empty($input_format_yyymmdd))
		 return '';

      list($pYear,$pMonth,$pDate) = explode('-',$input_format_yyymmdd);

      $day = ($pDate > 9)? $pDate : $rule_day[$pDate];

      if($pDate == '00') $output = '<font color=red>Error: Tidak ada tanggal pada bulan dan tahun tersebut!</font>';
      elseif($mode_font == 'upper') $output = $day.' '.strtoupper($rule_month[$pMonth]).' '.$pYear;
      else $output = $day.' '.$rule_month[$pMonth].' '.$pYear;

      return $output;
   }

   function converter_time($input)
   {
      list($pHour,$pMinute,$pSecond) = explode(':',$input);

      $output = $pHour.':'.$pMinute;

      return $output;
   }

}

/* ekaprakarsa@facebook.com */